//
//  HACAppDelegateDispatcher.h
//  HACDispatcher
//
//  Created by Chengjie on 2019/5/9.
//

#import <UIKit/UIKit.h>


NS_ASSUME_NONNULL_BEGIN

/**
 思路可参考
 https://github.com/cleexiang/AppDelegateDispatcher、
 但是这个作者写的某些实现的逻辑可能存在着争议，所以借鉴修改了下
 在此表示感谢cleexiang的思维启发，使用示范如下：
 
 #import "HACAppDelegateDispatcher.h"
 
 @interface AppDelegate ()
 @property (nonatomic, strong) HACAppDelegateDispatcher *dispatcher;
 @end
 
 @implementation AppDelegate
 
 - (HACAppDelegateDispatcher *)dispatcher {
     if (!_dispatcher) {
         _dispatcher = [[HACAppDelegateDispatcher alloc] initWithDlegates:@[
                                                                             @"HACTestAppDelegate",
                                                                             @"HACDemoAppDelegate",
                                                                             ]
                        ];
     }
     return _dispatcher;
 }
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     return [self.dispatcher application:application didFinishLaunchingWithOptions:launchOptions];
 }
 
 - (void)applicationWillResignActive:(UIApplication *)application {
     [self.dispatcher applicationWillResignActive:application];
 }
 
 ...
 
@end
 */
@interface HACAppDelegateDispatcher : NSObject <UIApplicationDelegate>

/**
 所有的业务AppDelegate
 */
@property (nonatomic, strong, readonly) NSMutableArray<id<UIApplicationDelegate>> *appDelegates;

/**
 组件化业务调用者

 @param delegates 所有要注册的类
 @return 返回一个调度者
 */
- (instancetype)initWithDlegates:(NSArray<NSString *> *)delegates;

@end

NS_ASSUME_NONNULL_END
